 'use strict'
var { initPointList } = require("../../points");
var { Point } = require("../../Point");
var list = initPointList(30);
console.log(list.filter(v => {
  return v.e
}).length)
var f;
var len00;
var dx, dy;
var t = 0.1;
function step() {
  for (let i = 0, len = list.length, item; item = list[i++];) {
    item.ax = 0;
    item.ay = 0;
    for (let k = i, ktem; ktem = list[k++];) {
      if (i != k) {
        var ep = (item.e ^ ktem.e) ? 1 : -1;
        len00 = Point.len(item, ktem);
        f = (ep * 1000) / (len00 * len00);
        // if (len00 > 20) // 大于20
        //   f = (ep * 100) / (len00 * len00);
        // else {
        //   f = len00 * 0.5;
        // }
        dx = (item.x - ktem.x) / len00 * f;
        dy = (item.y - ktem.y) / len00 * f;
        item.ax = -dx;
        item.ay = -dy;
        ktem.ax = dx;
        ktem.ay = dy;
      }
    }
    //  item.vx+=item.ax*0.0001;
    //  item.vy+=item.ay*0.0001;
  }
  for (let i = 0, item; item = list[i++];) {
    item.x += (item.vx) * t;
    item.y += (item.vy) * t;
    item.vx += item.ax * t;
    item.vy += item.ay * t;
  }
  module.exports.refesh && module.exports.refesh()
  requestAnimationFrame(step);
};
step()
module.exports = { list }